<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">

	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:101%;height:600px;">
			<div data-options="region:'center'" title="短信模板列表">
				<div>
					<table id="dg" class="table_style">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="easyui-dialog" closed="true" style="width:815px;height:350px;padding:10px">
			<iframe id="ifrmEdit" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../JS/common.js"></script>
	<script type="text/javascript" src='../../../JS/SHA-1.js'></script>
	<script>
		var currid = getID();
		var toolbarType =TOOLBAR_ADD+TOOLBAR_EDITOR;
		var content = AddToolBar(toolbarType);
		$("#toolbar").append(content);
		var DialogWidth = 500;
		var DialogHeight = 300;
		var AddDialog;

		/*添加信息*/
		function newdata() {
			var pLocation = "UI/Market/SMSModule/SMSModuleAdd.html?id=-1";
			$("#ifrmEdit").attr("src", pLocation); /*将plocation的值当作链接，并在ID=ifrmEdit的iframe中打开*/
			constructDialog($('#dlg'), '新增短信模板', DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		/*编辑信息*/
		function editdata() {
			var pLocation = "";
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('Info', "请选择你需要修改数据");
				return;
			}
			pLocation = "UI/Market/SMSModule/SMSModuleAdd.html?id=" + row.ID;
			$("#ifrmEdit").attr("src", pLocation); /*将plocation的值当作链接，并在ID=ifrmEdit的iframe中打开*/
			constructDialog($('#dlg'), '短信模板修改', DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		function destroy() { //删除
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('Info', "请选择你需要修改数据");
				return;
			}
			$.messager.confirm('Confirm', '是否删除', function(r) {
				if(r) {
					$.post(RemoteLinkAddress + "/smstemplate/delete.do", {
							ID: row.ID,
						},
						function(result) {
							if(result.msg == "success") {
								$.messager.alert({ // show success message
									title: '成功',
									msg: '删除成功'
								});
								$('#dg').datagrid('reload');
							} else {
								$.messager.alert({ // show error message
									title: 'Error',
									msg: result.msg
								});
							}
						},
						'json');
				}
			});
		}

		$('#dg').datagrid({
			url: RemoteLinkAddress + '/smstemplate/list.do',
			toolbar: '#toolbar',
			method: 'get',
			pagination: 'true',
			rownumbers: 'true',
			autoRowHeight: 'true',
			fitColumns: 'false',
			singleSelect: 'true',
			height: 350,
			columns: [
				[{
					field: 'ID',
					title: 'ID',
					width: '10%',
					align: 'center'
				}, {
					field: 'NAME',
					title: '名称',
					width: '10%',
					align: 'center'
				}, {
					field: 'CONTEXT',
					title: '模板内容',
					width: '77%',
					align: 'center'
				}, ]
			],
			onDblClickRow: function(index, row) {
				var pLocation = "UI/Market/SMSModule/SMSModuleAdd.html?id=" + row.ID;
				$("#ifrmEdit").attr("src", pLocation); /*将plocation的值当作链接，并在ID=ifrmEdit的iframe中打开*/
				constructDialog($('#dlg'), '短信模板修改', DialogWidth, DialogHeight);
				AddDialog.dialog('open');
			}
		});

		function dialogClose() {
			AddDialog.dialog('close');
		}
	</script>

</html>